package com.cdfive.demo.serviceA;

import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;

import java.util.Collections;

/**
 * @author xiejihan
 * @date 2019-01-03
 */
@Slf4j
@ImportResource("classpath:config/applicationContext.xml")
@SpringBootApplication(scanBasePackages = "com.cdfive")
public class ServiceAApplication {
    public static void main(String[] args) {

        FlowRule flowRule = new FlowRule();
        flowRule.setResource("com.cdfive.demo.serviceA.service.HelloService:hello(java.lang.String)");
        flowRule.setCount(1);
        flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
        flowRule.setLimitApp("default");
        FlowRuleManager.loadRules(Collections.singletonList(flowRule));

        SpringApplication.run(ServiceAApplication.class, args);
        log.info("ServiceA application started");
    }
}
